home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #15
/
Monster Media Number 15 (Monster Media)(July 1996).ISO
/
bbs_game
/
blackj20.zip
/
BLACK.SRC
< prev
next >
Wrap
Text File
|
1996-04-19
|
24KB
|
967 lines
# ┌──────────────────────────────────────────────────────────────────────────┐
# │ BLACK.SRC (Chuckle Box BlackJack) │
# │ │
# │ Version: 2.0 (Released 19 Apr 1996) for SBBS 2.20 - Rev B │
# │ Author: Robert Nykvist aka Chuckles@VERT │
# │ │
# │ Quick Start: 1. Move BLACK.SRC to your \EXEC directory. │
# │ 2. Edit paths in script as needed for your system. │
# │ 3. Compile BLACK.SRC with Baja compiler. │
# │ 4. You determine how to make script available. │
# │ │
# │ NOTE: This script WILL modify user credits, and uses │
# │ file I/O to create a log. Check the paths! │
# └──────────────────────────────────────────────────────────────────────────┘
!INCLUDE SBBSDEFS.INC
!INCLUDE FILE_IO.INC
# Define Integer Variables
int WINNINGS CARD COUNT TOTAL FILE TRACKPLAY
# Set WINNINGS to zero only upon entering the script.
set WINNINGS 0
set TRACKPLAY 0
# Top of Menu - Credit Check
# If user doesn't have 5 k Credits, send them on their way.
:top
compare_ars $C !5
if_true
crlf
print "rhSorry, you don't have enough credits play today."
crlf
print "rhTry again tomorrow...n"
crlf
crlf
pause
cmd_pop
goto byebye
end_if
# Display Menu
cls
print " hw4 Score Result n
crlf
print "n ┌────────────┬────────────┐"
crlf
print " │ hm0 - 8 n│ hm-25 k n│"
print " nhwChuckle Box BlackJackn
crlf
print " │ hm9 - 13 n│ hm-10 k n│"
print " hy Version 2.0n"
crlf
print " │ hg14 - 17 n│ hg+5 k n│"
crlf
print " │ hg18 - 20 n│ hg+25 k n│"
print " 4hy Your Credits :w @BYTESLEFT@ n"
crlf
print " │ hyBlack Jack n│ hy+50 k n│"
crlf
print " │ hrBusted n│ hr-25 k n│"
crlf
print " └────────────┴────────────┘n"
crlf
crlf
# Note Node Location & make sure things are flowing in SYNC.
node_action node_xtrn
# Display Prompt
compare_ars SYSOP
if_true
mnemonics " ~E)dit, ~V)iew, ~I)nfo, ~P)lay or ~Q)uit > "
else
mnemonics " ~V)iew, ~I)nfo, ~P)lay or ~Q)uit > "
end_if
# Get Key Input From User - ENTER allowed
sync
getkey EIPQV?\R
# Edit function for SysOp Only
cmdkey e
compare_ars SYSOP
if_true
crlf
crlf
setstr "c:\\sbbs\\blackjck.log"
ungetstr
edit_text_file
cmd_pop
goto top
end_if
end_cmd
# View last 16 lines of GUESS.LOG
cmdkey v
cls
crlf
print "hg──────────────────────────w│nk2 Black Jack Log nhw│g────────────────────────────n"
crlf
chkfile "c:\sbbs\blackjck.log"
if_true
setstr "c:\\sbbs\\blackjck.log"
printtail str 0 16
crlf
else
crlf
print "yh No one has played yet, or the SysOp has screwed up somewhere."
crlf
crlf
end_if
print "hg──────────────────────────────────────────────────────────────────────────────n"
crlf
crlf
pause
cmd_pop
goto top
end_cmd
# Display Instructions/Info
cmdkey I
cls
crlf
crlf
print " nhChuckle Box BlackJack - Ver 2.0"
crlf
print " yfor SBBS 2.20 B, by Robert Nykvist"
crlf
print "c The Chuckle Box BBS @ (334) 653-1888"
crlf
crlf
crlf
print "ìnc Each BlackJack hand costsihr 5 knc credits!"
crlf
print "ìncWhen you hHITnc, the hmcomputer ncwill deal you a card,"
crlf
print "ïand keep a running htotal ncof the value of your hHITsnc."
crlf
crlf
print "ÜFace card = face value."
crlf
print "önc Jack = hm11, ncQueen = hm12, ncKing = hm13nc"
crlf
crlf
print "ìWhen you hSTOP nchitting, the computer will hmprocess"
crlf
print "ènc credits according to the chart ncin the menu."
crlf
crlf
print "âCredits can hbuy ncyou hmextra ncon-line time using the Time/Credit hmBanknc!n"
crlf
crlf
crlf
pause
cmd_pop
goto top
end_cmd
# Wipe out display Prompt and go Play, but only for ANSI users.
cmdkey P
compare_ars $[
if_false
crlf
crlf
print "To play this game, you must be in ANSI mode....."
crlf
print "Non-ANSI mode detected. Returning you to BBS..."
crlf
crlf
pause
cmd_pop
goto byebye
end_if
print "1Hn n"
crlf
cmd_pop
goto play
end_cmd
# Wipe out display Prompt and Leave
cmdkey Q
print "1Hn n"
crlf
cmd_pop
goto leave
end_cmd
print "1Hn n"
crlf
# Hitting Enter or fallthrough goes to Play,
# again, checking for non-ANSI users.
compare_ars $[
if_false
crlf
crlf
print "To play this game, you must be in ANSI mode....."
crlf
print "Non-ANSI mode detected. Returning you to BBS..."
crlf
crlf
pause
cmd_pop
goto byebye
end_if
print "1Hn n"
crlf
cmd_pop
goto play
# Play BlackJack - Adjust Credits -5K for Ante,
# Keep track of WINNINGS, Reset Integer variables.
:play
add trackplay 1
adjust_user_credits -5
sub WINNINGS 5
set CARD 0
set COUNT 0
set TOTAL 0
# Switch/Case Loop using Integer Variable COUNT.
# Purpose is to alter prompt colors after each hit
# while updating totals. Easier for user to see changes.
# Many ANSI sequences used to control placement.
:choosecard
switch count
case 0
print "1H"
print "hcYour current score is: hm"
print TOTAL
print "1H"
print " "
print "1H"
yes_no "Hit"
if_true
cmd_pop
goto hit
else
cmd_pop
goto stay
end_if
end_case
case 1
print "1H"
print "hyYour current score is: hc"
print TOTAL
print "1H"
print " "
print "1H"
yes_no "Hit"
if_true
cmd_pop
goto hit
else
cmd_pop
goto stay
end_if
end_case
case 2
print "1H"
print "nmYour current score is: hy"
print TOTAL
print "1H"
print " "
print "1H"
yes_no "Hit"
if_true
cmd_pop
goto hit
else
cmd_pop
goto stay
end_if
end_case
case 3
print "1H"
print "hcYour current score is: hm"
print TOTAL
print "1H"
print " "
print "1H"
yes_no "Hit"
if_true
cmd_pop
goto hit
else
cmd_pop
goto stay
end_if
end_case
case 4
print "1H"
print "hgYour current score is: nc"
print TOTAL
print "1H"
print " "
print "1H"
yes_no "Hit"
if_true
cmd_pop
goto hit
else
cmd_pop
goto stay
end_if
end_case
case 5
print "1H"
print "hmYour current score is: nc"
print TOTAL
print "1H"
print " "
print "1H"
yes_no "Hit"
if_true
cmd_pop
goto hit
else
cmd_pop
goto stay
end_if
end_case
end_switch
# Player wants a Hit (Draw Card)
# Randomly choose 1-13 for CARD variable
# 0-12 becomes 1-13 by adding 1.
:hit
random CARD 12
add CARD 1
# Problem here is displaying cards with single digits
# as compared to double digit cards, not to mention
# a standard placement of each card for nice graphics.
# We again make use of Switch/Case loop, again using COUNT,
# and ANSI sequence codes to control placement.
:displaycard
switch count
case 0
# Is the card two digit or single digit?
# Double Digit card is one character wider...
# That's the reason for this long case/if loop
compare CARD 10
if_less
# Display first card Hit on column 1 (1H)
# This is assuming a 24 x 80 character screen.
print "1H"
print "hb╒════════╕ "
print "1H"
print "b│ c "
print CARD
print "b │ "
print "1H"
print "b│ │ "
print "1H"
# Letters CB? Chuckle Box of course. :)
# Customize this script as you see fit.
# But kindly give credit where credit is due.
print "b│ CB │ "
print "1H"
print "b│ │ "
print "1H"
print "b│ c"
print CARD
print "b │ "
print "1H"
print "b╘════════╛ "
print "1H"
print "wThe card is a: g"
print CARD
print " "
else
# 10 or greater is one character wider.
print "1H"
print "hb╒═════════╕ "
print "1H"
print "b│ c "
print CARD
print "b │ "
print "1H"
print "b│ │ "
print "1H"
print "b│ C B │ "
print "1H"
print "b│ │ "
print "1H"
print "b│ c"
print CARD
print "b │ "
print "1H"
print "b╘═════════╛ "
print "1H"
print "yThe card is a: c"
print CARD
print " "
end_if
end_case
case 1
compare CARD 10
if_less
# Display second card hit on column 15 (15H)
print "15H"
print "hb╒════════╕ "
print "15H"
print "b│ c "
print CARD
print "b │ "
print "15H"
print "b│ │ "
print "15H"
print "b│ CB │ "
print "15H"
print "b│ │ "
print "15H"
print "b│ c"
print CARD
print "b │ "
print "15H"
print "b╘════════╛ "
print "1H"
print "wThe card is a: g"
print CARD
print " "
else
print "15H"
print "hb╒═════════╕ "
print "15H"
print "b│ c"
print CARD
print "b │ "
print "15H"
print "b│ │ "
print "15H"
print "b│ C B │ "
print "15H"
print "b│ │ "
print "15H"
print "b│ c"
print CARD
print "b │ "
print "15H"
print "b╘═════════╛ "
print "1H"
print "yThe card is a: c"
print CARD
print " "
end_if
end_case
case 2
compare CARD 10
if_less
# Display third card hit on column 30 (30H)
print "30H"
print "hb╒════════╕ "
print "30H"
print "b│ c "
print CARD
print "b │ "
print "30H"
print "b│ │ "
print "30H"
print "b│ CB │ "
print "30H"
print "b│ │ "
print "30H"
print "b│c "
print CARD
print "b │ "
print "30H"
print "b╘════════╛ "
print "1H"
print "wThe card is a: g"
print CARD
print " "
else
print "30H"
print "hb╒═════════╕ "
print "30H"
print "b│ c"
print CARD
print "b │ "
print "30H"
print "b│ │ "
print "30H"
print "b│ C B │ "
print "30H"
print "b│ │ "
print "30H"
print "b│ c"
print CARD
print "b │ "
print "30H"
print "b╘═════════╛ "
print "1H"
print "yThe card is a: c"
print CARD
print " "
end_if
end_case
case 3
compare CARD 10
if_less
# Display fourth card hit on column 45 (45H)
print "45H"
print "hb╒════════╕ "
print "45H"
print "b│ c "
print CARD
print "b │ "
print "45H"
print "b│ │ "
print "45H"
print "b│ CB │ "
print "45H"
print "b│ │ "
print "45H"
print "b│ c"
print CARD
print "b │ "
print "45H"
print "b╘════════╛ "
print "1H"
print "wThe card is a: g"
print CARD
print " "
else
print "45H"
print "hb╒═════════╕ "
print "45H"
print "b│ c"
print CARD
print "b │ "
print "45H"
print "b│ │ "
print "45H"
print "b│ C B │ "
print "45H"
print "b│ │ "
print "45H"
print "b│ c"
print CARD
print "b │ "
print "45H"
print "b╘═════════╛ "
print "1H"
print "yThe card is a: c"
print CARD
print " "
end_if
end_case
case 4
compare CARD 10
if_less
# Display fifth & last card pick on column 60 (60H)
print "60H"
print "hb╒════════╕ "
print "60H"
print "b│ c "
print CARD
print "b │ "
print "60H"
print "b│ │ "
print "60H"
print "b│ CB │ "
print "60H"
print "b│ │ "
print "60H"
print "b│c "
print CARD
print "b │ "
print "60H"
print "b╘════════╛ "
print "1H"
print "wThe card is a: g"
print CARD
print " "
else
print "60H"
print "hb╒═════════╕ "
print "60H"
print "b│ c"
print CARD
print "b │ "
print "60H"
print "b│ │ "
print "60H"
print "b│ C B │ "
print "60H"
print "b│ │ "
print "60H"
print "b│ c"
print CARD
print "b │ "
print "60H"
print "b╘═════════╛ "
print "1H"
print "yThe card is a: c"
print CARD
print " "
end_if
end_case
end_switch
# COUNT is used to keep track of Hits or cards drawn.
# After drawing a CARD, it is added to variable TOTAL.
add COUNT 1
add TOTAL CARD
# There is a BONUS for those who draw 5 cards
# Checking for it here.
compare COUNT 5
if_true
cmd_pop
goto bigtest
end_if
# Checking TOTAL for Blackjack.
compare TOTAL 21
if_true
cmd_pop
goto super
end_if
# Is TOTAL less than 21? See if they want another HIT.
compare TOTAL 21
if_less
cmd_pop
goto choosecard
end_if
# TOTAL over 21? Oh Crap... BUSTED.
compare TOTAL 21
if_greater
cmd_pop
goto crap
end_if
# When they don't want another HIT - they STAY.
# Now we have to determine what CREDIT action
# to take based upon their card TOTAL.
# See Menu for what TOTALs earn what CREDITS.
# Feel Free to customize the CREDIT structures.
# Checking here for a TOTAL less than 8.
:stay
compare TOTAL 8
if_less_or_equal
cmd_pop
goto losetwofive
else
cmd_pop
goto testtwo
end_if
# TOTAL Less than 8? Yikes! -25
# Again using ANSI sequences for placement of text, or clearing of text.
:losetwofive
print "1H"
print "hwYour total for this hand was: hb"
print TOTAL
print " n"
crlf
print " n"
crlf
print "hmThe SysOp Chuckles as he snatches hr25 khm of your credits!n"
crlf
print "1Hn n\r"
pause
# Adjusting credits accordingly and tracking their overall winnings.
adjust_user_credits -25
sub WINNINGS 25
cmd_pop
goto top
# Checking for TOTAL between 9 & 13
:testtwo
compare TOTAL 13
if_less_or_equal
cmd_pop
goto loseten
else
cmd_pop
goto testthree
end_if
# TOTAL between 9-13. Too Bad. -10
:loseten
print "1H"
print "hwYour total for this hand was: hb"
print TOTAL
print " n"
crlf
print " n"
crlf
Print "hmSay goodbye to hr10 khm of your Credits for staying with 13 or less!n"
crlf
print "1Hn n\r"
pause
adjust_user_credits -10
sub WINNINGS 10
cmd_pop
goto top
# Checking for TOTAL between 14 & 17
:testthree
compare TOTAL 17
if_less_or_equal
cmd_pop
goto gainfive
else
cmd_pop
goto testfour
end_if
# TOTAL between 14-17. They played it SAFE. +5
# Since it cost 5 to play, they gain or lose nothing.
:gainfive
print "1H"
print "hwYour total for this hand was: hb"
print TOTAL
print " n"
crlf
print " n"
crlf
print "hmSmart Move! Playing it safe earned youhr 5 khm Credits.n"
crlf
print "1Hn n\r"
pause
adjust_user_credits 5
add WINNINGS 5
cmd_pop
goto top
# TOTAL between 18-20. Ahh, a Winner! +25
:testfour
print "1H"
print "hwYour total for this hand was: hb"
print TOTAL
print " n"
crlf
print " n"
crlf
print_remote ""
print "hmWow! What luck @USER@! You win r25 km Credits!!!!n"
crlf
print "1Hn n\r"
pause
adjust_user_credits 25
add WINNINGS 25
cmd_pop
goto top
# TOTAL = 21 CHUCKLE BLACK JACK! +50
:super
print "1H"
print "hwYour total for this hand was: hb"
print TOTAL
print " n"
crlf
print " n"
crlf
# Send them fancy stereo feedback for winning. <Chuckle>
print_remote ""
print "hmYou've hit 21-BLACKJACK you lucky hacker you!!!n"
crlf
print "hyThe SysOp addsr 50 ky credits to your account with a scowl...n"
crlf
print "1Hn n\r"
pause
adjust_user_credits 50
add WINNINGS 50
cmd_pop
goto top
# Took 5 cards and the TOTAL was 21 or less?
# Not easy to do so reward them! +150
:overfive
print "1H"
print "hwYour total for this hand was: hb"
print TOTAL
print " n"
crlf
print " n"
crlf
print_remote ""
print "hmYou took 5 cards and have 21 or less. You get Bonus Credits!!!n"
crlf
print "hyThe SysOp painfully addsr 150 ky credits to your account with a howl...n"
crlf
print "1Hn n\r"
pause
adjust_user_credits 150
add WINNINGS 150
cmd_pop
goto top
# TOTAL over 21. BUSTED! -25
:crap
print "1H"
print "hwYour total for this hand was: hb"
print TOTAL
print " n"
crlf
print " n"
crlf
print "hmUh Oh . . . You've busted big time with a score of: hr"
print TOTAL
print ".n"
crlf
print "hyThe SysOp pockets away r25 ky of your credits with a Chuckle...n"
crlf
print "1Hn n\r"
pause
adjust_user_credits -25
sub WINNINGS 25
cmd_pop
goto top
# If COUNT in a previous check indicated 5 cards had been drawn,
# this is the bigtest to see if they win big CREDITS.
:bigtest
compare TOTAL 21
if_less_or_equal
cmd_pop
goto overfive
end_if
compare TOTAL 21
if_greater
cmd_pop
goto crap
end_if
# Leaving so soon? Let's see if they won or lost
# and send them the appropriate feedback.
# They started out with WINNINGS = 0
:leave
# No trackplay = No play. Bypass logging no-play activity.
compare trackplay 0
if_equal
cmd_pop
goto byebye
end_if
compare WINNINGS 0
if_equal
cmd_pop
goto nochange
end_if
compare WINNINGS 0
if_greater
cmd_pop
goto playerwon
else
cmd_pop
goto userlost
end_if
# No winings - No loss.
:nochange
crlf
crlf
print "hyYou came out exactly hmEVENhy @USER@.n"
crlf
crlf
pause
# Append GUESS.LOG for No Change. Plays/User/Date/Credits
FOPEN file O_CREAT|O_WRONLY|O_APPEND "c:\sbbs\blackjck.log"
str uno dos
copy str trackplay
# Number of Plays Info. Display formality. Print Play or Plays?
compare trackplay 1
if_equal
fprintf file "mh%s ngplay by wh" str
else
fprintf file "mh%s ngplays by wh" str
end_if
# User Alias
fwrite file _useron.alias
set uno " ngon hy"
fprintf file "%s" uno
int t
time t
time_str str t
shift_str 4
# Date/Time
fprintf file "%s" str
# Credit Results - Adding a return on the end of the line.
set dos "ng. Results: rhEven\r\n"
fprintf file "%s" dos
FCLOSE file
cmd_pop
goto byebye
# TOTAL above zero - Player Won Credits!
:playerwon
crlf
crlf
print "hyYou've won a grand total of hm"
print WINNINGS
print " hyk Credits @USER@.n
crlf
crlf
pause
FOPEN file O_CREAT|O_WRONLY|O_APPEND "c:\sbbs\blackjck.log"
str uno dos
copy str trackplay
compare trackplay 1
if_equal
fprintf file "mh%s ngplay by wh" str
else
fprintf file "mh%s ngplays by wh" str
end_if
fwrite file _useron.alias
set uno " ngon hy"
fprintf file "%s" uno
int t
time t
time_str str t
shift_str 4
fprintf file "%s" str
set dos "ng. Results: wh+"
fprintf file "%s" dos
copy str winnings
fprintf file "%s k\r\n" str
FCLOSE file
cmd_pop
goto byebye
# TOTAL below 0 (negative) User Lost!
:userlost
crlf
crlf
print "hyYou lost a total of hm"
print WINNINGS
print " hyk Credits @USER@n"
crlf
crlf
pause
FOPEN file O_CREAT|O_WRONLY|O_APPEND "c:\sbbs\blackjck.log"
str uno dos
copy str trackplay
compare trackplay 1
if_equal
fprintf file "mh%s ngplay by wh" str
else
fprintf file "mh%s ngplays by wh" str
end_if
fwrite file _useron.alias
set uno " ngon hy"
fprintf file "%s" uno
int t
time t
time_str str t
shift_str 4
fprintf file "%s" str
set dos "ng. Results: rh"
fprintf file "%s" dos
copy str winnings
fprintf file "%s k\r\n" str
FCLOSE file
cmd_pop
goto byebye
# Exiting Script.
:byebye